package com.data.center.controller.mongo;
import com.data.center.entity.mongo.organization;
import com.data.center.service.mongo.OrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("/organizations")
public class MongoOrganizationController {

    @Autowired
    private OrganizationService service;

    @PostMapping
    public organization createOrganization(@RequestBody organization organization) {
        return service.saveOrganization(organization);
    }

    @GetMapping("/{id}")
    public organization getOrganizationById(@PathVariable String id) {
        return service.getOrganizationById(id).orElse(null);
    }

    @GetMapping
    public List<organization> getAllOrganizations() {
        return service.getAllOrganizations();
    }

    @DeleteMapping("/{id}")
    public void deleteOrganization(@PathVariable String id) {
        service.deleteOrganization(id);
    }
}
